#!/usr/bin/python2.6
#
#/export/users/ADB/android-sdk-linux_x86/platform-tools/adb shell
#/export/users/ADB/android-ndk-r4-crystax/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-g++
#/export/users/ADB/android-ndk-r4-crystax/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-gcc
''' options:
    -sysdir <dir>                  search for system disk images in <dir>
    -system <file>                 read initial system image from <file>
    -datadir <dir>                 write user data into <dir>
    -kernel <file>                 use specific emulated kernel
    -ramdisk <file>                ramdisk image (default <system>/ramdisk.img
    -image <file>                  obsolete, use -system <file> instead
    -initdata <file>               same as '-init-data <file>'
    -data <file>                   data image (default <datadir>/userdata-qemu.img
    -partition-size <size>         system/data partition size in MBs
    -cache <file>                  cache partition image (default is temporary file)
    -no-cache                      disable the cache partition
    -nocache                       same as -no-cache
    -sdcard <file>                 SD card image (default <system>/sdcard.img
    -snapstorage <file>            file that contains all state snapshots (default <datadir>/snapshots.img)
    -no-snapstorage                do not mount a snapshot storage file (this disables all snapshot functionality)
    -snapshot <name>               name of snapshot within storage file for auto-start and auto-save (default 'default-boot')
    -no-snapshot                   perform a full boot and do not do not auto-save, but qemu vmload and vmsave operate on snapstorage
    -no-snapshot-save              do not auto-save to snapshot on exit: abandon changed state
    -no-snapshot-load              do not auto-start from snapshot: perform a full boot
    -snapshot-list                 show a list of available snapshots
    -wipe-data                     reset the use data image (copy it from initdata)
    -avd <name>                    use a specific android virtual device
    -memory <size>                 physical RAM size in MBs
    -netfast                       disable network shaping
    -trace <name>                  enable code profiling (F9 to start)
    -show-kernel                   display kernel messages
    -shell                         enable root shell on current terminal
    -no-jni                        disable JNI checks in the Dalvik runtime
    -nojni                         same as -no-jni
    -logcat <tags>                 enable logcat output with given tags
    -no-audio                      disable audio support
    -noaudio                       same as -no-audio
    -audio <backend>               use specific audio backend
    -raw-keys                      disable Unicode keyboard reverse-mapping
    -radio <device>                redirect radio modem interface to character device
    -port <port>                   TCP port that will be used for the console
    -ports <consoleport>,<adbport> TCP ports used for the console and adb bridge
    -onion-rotation 0|1|2|3        specify onion-skin rotation
    -scale <scale>                 scale emulator window
    -dpi-device <dpi>              specify device's resolution in dpi (default 165)
    -http-proxy <proxy>            make TCP connections through a HTTP/HTTPS proxy
    -timezone <timezone>           use this timezone instead of the host's default
    -dns-server <servers>          use this DNS server(s) in the emulated system
    -cpu-delay <cpudelay>          throttle CPU emulation
    -no-boot-anim                  disable animation for faster boot
    -no-window                     disable graphical window display
    -version                       display emulator version number
    -gps <device>                  redirect NMEA GPS to character device
    -keyset <name>                 specify keyset file name
    -shell-serial <device>         specific character device for root shell
    -old-system                    support old (pre 1.4) system images
    -tcpdump <file>                capture network packets to file
    -bootchart <timeout>           enable bootcharting
    -prop <name>=<value>           set system property on boot
    -shared-net-id <number>        join the shared network, using IP address 10.1.2.<number>
    -memcheck <flags>              enable memory access checking
'''
import os

ROOT='/export/users/ADB/android-sdk-linux_x86/'

android='tools/android '
emulator='tools/emulator '

def _appcreate(ID, name, path, activity, package):
	'''$./android create project 
			--target <target_ID> --name <your_project_name> --path /path/to/your/project --activity <your_activity_name> --package <your_package_namespace>'''
	params='create project --target %i --name %s --path %s --activity %s --package %s' % (ID, name, path, activity, package)
	cmd = [cmd, ROOT + cmd]
	status = os.spawnv(os.P_WAIT, cmd[0], cmd[1])
	if status > 0:
		return True
	else:
		return False
		
def _appupdate(name, ID, path):
	'''$./android update project --name <project_name> --target <target_ID> --path <path_to_your_project>'''
	
	params='update project--name %s  --target %i --path %s' % (name, ID, path)

	cmd = [cmd, ROOT + cmd]
	status = os.spawnv(os.P_WAIT, cmd[0], cmd[1])
	if status > 0:
		return True
	else:
		return False
		
def _targets():
	'''  android list targets'''
	params='list targets'
	cmd = [cmd, ROOT + cmd]
	status = os.spawnv(os.P_WAIT, cmd[0], cmd[1])
	if status > 0:
		return True
	else:
		return False

def _libcreate(name, ID, path, package):
	'''android create 
			lib-project --name <your_project_name> --target <target_ID> --path path/to/your/project --package <your_library_package_namespace>'''
	params='lib-project --name %s --target %i --path %s --package %s' % (name, ID, path, package)
	cmd = [cmd, ROOT + cmd]
	status = os.spawnv(os.P_WAIT, cmd[0], cmd[1])
	if status > 0:
		return True
	else:
		return False
		
def _libupdate(name, ID, path, package):
	'''android update 
			lib-project --name <your_project_name> --target <target_ID> --path path/to/your/project --package <your_library_package_namespace>'''
	params='lib-project --name %s --target %i --path %s --package %s' % (name, ID, path, package)
	cmd = [cmd, ROOT + cmd]
	status = os.spawnv(os.P_WAIT, cmd[0], cmd[1])
	if status > 0:
		return True
	else:
		return False
		
def _snapshotlist(avd):
	params='emulator -avd %s -snapshot-list' % (avd)
		cmd = [emulator, ROOT + emulator]
	status = os.spawnv(os.P_WAIT, cmd[0], cmd[1])
	if status > 0:
		return True
	else:
		return False
		
_snapshotlist('SamsungI5500L')
